package edu.spec.student.dao.impl;

import edu.spec.student.dao.iface.ILessonDao;
import edu.spec.student.model.lesson.Lesson;
import org.madgecko.basic.dao.BaseDao;
import org.madgecko.basic.kit.BasicKit;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by MadFrog on 2017/10/13.
 */
@Repository
public class LessonDao extends BaseDao<Lesson> implements ILessonDao {
    @Override
    public List<Lesson> listLessonByCourse(Integer courseId) {
        String hql = "";
        if(BasicKit.isEmpty(courseId)){
            hql = "from Lesson l";
        }else {
            hql = "from Lesson l where l.course.id=" + courseId;
        }
        return this.list(hql);
    }
}
